<!--
 * @Author: your name
 * @Date: 2021-09-07 09:19:22
 * @LastEditTime: 2021-09-07 09:28:41
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\5-javascript\day12\2-DOM节点追加.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="parent">
        <div class="child">1</div>
        <div class="child">2</div>
        <div class="child">3</div>
        <div class="child">4</div>
    </div>
</body>
<script>
    //创建一个div节点,用myDiv接收
    //var myDiv = document.createElement("div");
    //在创建的节点加入文本内容
    //myDiv.innerText = 5;
    //根据类名parent查找
    var rootDiv = document.getElementsByClassName("parent")[0];
    var firstDiv = document.getElementsByClassName("child")[0];
    //把myDiv追加到rootDiv后面
    //rootDiv.appendChild(myDiv);
    rootDiv.appendChild(firstDiv);
</script>

</html>